import $ from "jquery";
import {url} from "../../util/config";
import {success,error as exception} from "../../util/responseStatus";
import {closeStatus, openStatus} from "../../store/action";
import {message} from "antd";
import login from "../login";
function getNewLogin() {
    return previewActivityList()
}
export default function previewActivityList() {
    let list = [];
    let token = localStorage.getItem("token")

    $.ajax({
        async:false,
        method:'GET',
        headers: {
            'Accept': "application/json",
            'Authorization': token
        },
        url: url.api_url+`index/PreviewActivityList`,
        success: function (result) {
            let tmp = result.result;
            if(tmp=="Token過期請重新登錄"){
                login(localStorage.getItem("account"), localStorage.getItem("password"));
                list = getNewLogin()
            }else {
                list = tmp.map(item=>{
                    return {
                        new:item.ARTICLE_NEW,
                        key:item.ID,
                        name:item.NAME,
                        figure:item.FIGURE,
                        isEnd:item.FLAG,
                        createTime:item.CREATE_DATE,
                        updateTime:item.UPDATE_DATE
                    }
                });
            }
        },
        error:function (error) {
            message.error("请求异常");
        }
    })
    return list

}
